home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-01-29 | 2.3 KB | 68 lines | [TEXT/IGR0] |
- // CopyImageSubset
- // copies a subrange of an image displayed in an image plot.
- // To use, drag out a marquee in an image plot, click within the marquee,
- // and choose "CopyImageSubset" from the popup menu that appears.
-
- #include <Strings as Lists>
- #include <Keyword-Value>
- #include <Graph Utility Procs> version >= 1.2
-
- Proc CopyImageSubset() : GraphMarquee
- Silent 1;PauseUpdate
- String list= ImageNameList("",";")
- if( strlen(GetStrFromList(list, 1, ";")) ) // two or more images, comment this test out to make it work with the first of several images
- Abort "CopyImageSubset works only with a single image in a graph"
- endif
- String imagePlot = GetStrFromList(list, 0, ";")
- if (strlen(imagePlot)) // one image
- String info,vaxis,haxis,image,df,xwave,ywave
- Variable i
- info=ImageInfo("",imagePlot,0)
- vaxis=StrByKey("YAXIS",info)
- haxis=StrByKey("XAXIS",info)
- image=StrByKey("ZWAVE",info)
- df=StrByKey("ZWAVEDF",info)
- xwave=StrByKey("XWAVE",info)
- ywave=StrByKey("YWAVE",info)
- if( strlen(xwave)+strlen(ywave) )
- Abort "CopyImageSubset does not work on images with X or Y waves"
- endif
- string modInfo=StrByKey("RECREATION",info)
- info= AxisInfo("",haxis)
- String axisFlags= StrByKey("AXFLAG",info)
- info= AxisInfo("",vaxis)
- axisFlags+=StrByKey("AXFLAG",info)
- String winStyle= WinRecreation("",1)
- Variable swapxy= strsearch(winStyle,"swapXY=1",0) >= 0
- GetMarquee/K $haxis,$vaxis
- if( V_Flag != 1)
- Abort "CopyImageSubset() requires a marquee in the target graph"
- endif
- // copy the marqueed image subset into a clean, liberal, unique name.
- String copy=UniqueName(CleanupName(image+"Copy",1),1,0)
- CopyMatrix(df+image,copy,V_left,V_right,V_top,V_bottom,swapxy)
- // make a graph just like the source graph
- copy= PossiblyQuoteName(copy) // always use PossiblyQuoteName with Execute
- Preferences 1
- Display;Execute "AppendImage"+axisFlags+" "+copy
- if( strlen(modInfo) )
- Execute "ModifyImage "+copy+" "+modInfo
- endif
- ApplyStyleMacro(winStyle)
- TextBox/E/A=MT "\{ImageNameList(\""+WinName(0,1)+"\",\" \")}"
- else // no images
- Abort "No Image in graph"
- endif
- End
-
-
- Proc CopyMatrix(inmatrix,outmatrix,left,right,top,bottom,swapxy)
- String inmatrix,outmatrix
- Variable left,right,top,bottom,swapxy
-
- if( swapxy )
- Duplicate/O/R=(bottom,top)(left,right) $inmatrix,$outmatrix
- else
- Duplicate/O/R=(left,right)(bottom,top) $inmatrix,$outmatrix
- endif
- End